{extend name="base" /}
{block name="body"}
<div class="layui-card">
	<div class="layui-card-header">
		<form action="{:url('admin/scholar/index')}" class="layui-form" method="get">
			<div class="layui-form-item">
				<div class="layui-inline">
					搜索
				</div>
				<div class="layui-inline">
					<input type="text" name="name" value="{:input('name')}" autocomplete="off" class="layui-input"/>
				</div>
				<div class="layui-inline">
					学者编号
				</div>
				<div class="layui-inline">
					<input type="text" name="kid" value="{:input('kid')}" autocomplete="off" class="layui-input"/>
				</div>
				<div class="layui-inline">
					机构
				</div>
				<div class="layui-inline">
					<select name="institute">
						<option value="">全部机构</option>
						{foreach name="institute" item="v"}
						<option value="{$v.institute}" {if condition="input('institute') eq $v.institute" }selected="selected"{/if}>{$v.institute}</option>
						{/foreach}
					</select>
				</div>
				<div class="layui-inline">
					职称
				</div>
				<div class="layui-inline">
					<select name="professional_title">
						<option value="">全部职称</option>
						{foreach name="professionalTitle" item="v"}
						<option value="{$v.professional_title}" {if condition="input('professional_title') eq $v.professional_title" }selected="selected"{/if}>{$v.professional_title}</option>
						{/foreach}
					</select>
				</div>
				<div class="layui-inline">
					籍贯
				</div>
				<div class="layui-inline">
					<select name="hometown" class="province-selector">
						<option value="">全部</option>
						<option value="北京" {if condition="input('hometown') eq '北京'" }selected="selected"{/if}>北京市</option>
						<option value="天津" {if condition="input('hometown') eq '天津'" }selected="selected"{/if}>天津市</option>
						<option value="河北" {if condition="input('hometown') eq '河北'" }selected="selected"{/if}>河北省</option>
						<option value="山西" {if condition="input('hometown') eq '山西'" }selected="selected"{/if}>山西省</option>
						<option value="内蒙" {if condition="input('hometown') eq '内蒙'" }selected="selected"{/if}>内蒙古自治区</option>
						<option value="辽宁" {if condition="input('hometown') eq '辽宁'" }selected="selected"{/if}>辽宁省</option>
						<option value="吉林" {if condition="input('hometown') eq '吉林'" }selected="selected"{/if}>吉林省</option>
						<option value="黑龙江" {if condition="input('hometown') eq '黑龙江'" }selected="selected"{/if}>黑龙江省</option>
						<option value="上海" {if condition="input('hometown') eq '上海'" }selected="selected"{/if}>上海市</option>
						<option value="江苏" {if condition="input('hometown') eq '江苏'" }selected="selected"{/if}>江苏省</option>
						<option value="浙江" {if condition="input('hometown') eq '浙江'" }selected="selected"{/if}>浙江省</option>
						<option value="安徽" {if condition="input('hometown') eq '安徽'" }selected="selected"{/if}>安徽省</option>
						<option value="福建" {if condition="input('hometown') eq '福建'" }selected="selected"{/if}>福建省</option>
						<option value="江西" {if condition="input('hometown') eq '江西'" }selected="selected"{/if}>江西省</option>
						<option value="山东" {if condition="input('hometown') eq '山东'" }selected="selected"{/if}>山东省</option>
						<option value="河南" {if condition="input('hometown') eq '河南'" }selected="selected"{/if}>河南省</option>
						<option value="湖北" {if condition="input('hometown') eq '湖北'" }selected="selected"{/if}>湖北省</option>
						<option value="湖南" {if condition="input('hometown') eq '湖南'" }selected="selected"{/if}>湖南省</option>
						<option value="广东" {if condition="input('hometown') eq '广东'" }selected="selected"{/if}>广东省</option>
						<option value="广西" {if condition="input('hometown') eq '广西'" }selected="selected"{/if}>广西壮族自治区</option>
						<option value="海南" {if condition="input('hometown') eq '海南'" }selected="selected"{/if}>海南省</option>
						<option value="重庆" {if condition="input('hometown') eq '重庆'" }selected="selected"{/if}>重庆市</option>
						<option value="四川" {if condition="input('hometown') eq '四川'" }selected="selected"{/if}>四川省</option>
						<option value="贵州" {if condition="input('hometown') eq '贵州'" }selected="selected"{/if}>贵州省</option>
						<option value="云南" {if condition="input('hometown') eq '云南'" }selected="selected"{/if}>云南省</option>
						<option value="西藏" {if condition="input('hometown') eq '西藏'" }selected="selected"{/if}>西藏自治区</option>
						<option value="陕西" {if condition="input('hometown') eq '陕西'" }selected="selected"{/if}>陕西省</option>
						<option value="甘肃" {if condition="input('hometown') eq '甘肃'" }selected="selected"{/if}>甘肃省</option>
						<option value="青海" {if condition="input('hometown') eq '青海'" }selected="selected"{/if}>青海省</option>
						<option value="宁夏" {if condition="input('hometown') eq '宁夏'" }selected="selected"{/if}>宁夏回族自治区</option>
						<option value="新疆" {if condition="input('hometown') eq '新疆'" }selected="selected"{/if}>新疆维吾尔自治区</option>
						<option value="台湾" {if condition="input('hometown') eq '台湾'" }selected="selected"{/if}>台湾省</option>
						<option value="香港" {if condition="input('hometown') eq '香港'" }selected="selected"{/if}>香港特别行政区</option>
						<option value="澳门" {if condition="input('hometown') eq '澳门'" }selected="selected"{/if}>澳门特别行政区</option>
					</select>
				</div>
				<div class="layui-inline">
					<button class="layui-btn layui-btn-normal ajax-search"><i class="fa fa-search"></i></button>
				</div>
			</div>
		</form>
	</div>
	<div class="layui-card-body">
        <div class="layui-btn-group">
		    <a onclick="add()" class="layui-btn"><i class="fa fa-plus-circle"></i> 添加学者</a>
			<a onclick="importData()" class="layui-btn"><i class="fa fa-plus-circle"></i> 导入学者</a>
			<a href="{:url('admin/scholar/downloadOrUpload')}" class="layui-btn"><i class="fa fa-download"></i> 样例下载</a>
			<a href="{:url('admin/scholar/checkPass')}" class="layui-btn layui-btn-normal ajax-batch"><i class="fa fa-rocket"></i> 审核通过</a>
			<a onclick="multiPush()" class="layui-btn layui-btn-danger"><i class="fa fa-rocket"></i> 审核不通过</a>
		</div>
		<table class="layui-table layui-form">
			<thead>
			<tr>
				<th><input type="checkbox" lay-skin="primary" lay-filter="*"></th>
				<th>学者编号</th>
				<th>姓名</th>
				<th>机构</th>
				<th>性别</th>
				<th>邮箱</th>
				<th>手机号</th>
				<th>职称</th>
				<th>入职时间</th>
				<th>奖惩信息</th>
				<th>履历</th>
				<th>操作</th>
				<th>审核状态</th>
			</tr>
			</thead>
			<tbody>
			{foreach name="list" item="v" empty="$empty"}
			<tr>
				<td><input type="checkbox" name="id" value="{$v.id}" lay-skin="primary"></td>
				<td>{$v.kid}</td>
				<td>{$v.scholar_name}</td>
				<td>{$v.institute}</td>
				<td>
					{if condition="$v.sex == 1"}男
					{elseif condition="$v.sex == 2"}女
					{else/}未知
					{/if}
				</td>
				<td>{$v.email}</td>
				<td>{$v.phone}</td>
				<td>{$v.professional_title}</td>
				<td>{$v.entrant_time}</td>
				<td>
					<a onclick="viewRewardAndPunish({$v.id}, '{$v.kid}')" class="layui-btn layui-btn-xs layui-btn-normal"><i class="fa fa-edit"></i> 点击查看</a>
				</td>
				<td>
					<a onclick="viewResume({$v.id}, '{$v.kid}')" class="layui-btn layui-btn-xs layui-btn-normal"><i class="fa fa-edit"></i> 点击查看</a>
				</td>
				<td>
					<a onclick="edit({$v.id}, {$v.kid})" class="layui-btn layui-btn-xs layui-btn-normal"><i class="fa fa-edit"></i> 编辑</a>
				</td>
				<td>
					{if $v.is_check == 0}<label>待审核</label>
					{elseif $v.is_check == 1}<label style="color: #00FF00">已审核</label>
					{elseif $v.is_check == 2}<label style="color: #af0000">审核未通过</label>
					{/if}
				</td>
			</tr>
			{/foreach}
			</tbody>
		</table>
		<div class="page">{$list->render()}</div>
	</div>
</div>
{/block}
{block name="js"}
<script>
	//iframe 层
	function add() {
		layer.open({
			type: 2,
			title: '添加学者',
			shadeClose: true,
			shade: false,
			area: ['860px', '600px'],
			content: '/admin/scholar/add',
		});
	}

	function edit(id, kid) {
		layer.open({
			type: 2,
			title: '修改学者',
			shadeClose: true,
			shade: false,
			area: ['860px', '600px'],
			content: '/admin/scholar/edit?id=' + id + '&kid=' + kid,
		});
	}

	function viewRewardAndPunish(id, kid) {
		//iframe 层
		layer.open({
			type: 2,
			title: '奖惩信息',
			shadeClose: true,
			shade: false,
			area: ['860px', '600px'],
			content: '/admin/scholar/toRewardAndPunish?id=' + id + '&kid=' + kid,
		});
	}

	function viewResume(id, kid) {
		//iframe 层
		layer.open({
			type: 2,
			title: '履历',
			shadeClose: true,
			shade: false,
			area: ['860px', '600px'],
			content: '/admin/scholar/resumeDetail?id=' + id + '&kid=' + kid,
		});
	}

	function importData() {
		layer.open({
			type: 2,
			title: '导入学者',
			shadeClose: true,
			shade: false,
			area: ['480px', '320px'],
			content: '/admin/scholar/importScholar',
		});
	}

	function multiPush() {
		var userIds = [];
		$('.layui-table tbody input[lay-skin="primary"]:checked').each(function (i) {
			userIds[i] = $(this).val();
		});
		if (userIds === undefined || userIds.length == 0) {
			layer.msg('请选择数据');
			return false;
		}
		layer.open({
			type: 2,
			title: '消息',
			shadeClose: true,
			shade: false,
			area: ['860px', '600px'],
			content: '/admin/push/toPush?userId=' + userIds + '&template=4',
		});
	}
</script>
{/block}